﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Data.SqlClient;
using QA_System.QASysDataSetTableAdapters;

namespace QA_System
{
    public class Collection
    {
        private static CollectionTableAdapter collectionAdapter = new CollectionTableAdapter();

        public static QASysDataSet.CollectionDataTable GetAllCollection()
        {
            QASysDataSet.CollectionDataTable collectionTable = collectionAdapter.GetData();
            return collectionTable;
        }

        public static Collectionfield GetByCollectionId(int collectionId)
        {
            QASysDataSet.CollectionDataTable collectionTable = collectionAdapter.GetDataByCollectionId(collectionId);
            if (collectionTable.Rows.Count > 0)
            {
                Collectionfield FData = new Collectionfield();
                FData.Art_ID = int.Parse(collectionTable.Rows[0]["Art_Id"].ToString());
                FData.Collect_Id = int.Parse(collectionTable.Rows[0]["Collect_Id"].ToString());
                FData.List_Paint_Id = collectionTable.Rows[0]["List_Paint_Id"].ToString();
                if (collectionTable.Rows[0]["Name"] != null) FData.Name = collectionTable.Rows[0]["Name"].ToString();
                else FData.Name = "";
                return (FData);
            }
            else
                return null;            
        }
    }
}
